package com.chnbst.bstyun.service.impl;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.chnbst.bstyun.core.base.BaseService;
import com.chnbst.bstyun.core.common.helper.DaoHelper;
import com.chnbst.bstyun.model.pojo.Deal;
import com.chnbst.bstyun.model.vo.DealVo;
import com.chnbst.bstyun.service.DealService;

/**
 * @author WangXinLei
 * @date 2014年9月22日 下午17:55  
 */

@Transactional
@Service
public class DealServiceImpl  extends BaseService implements DealService {

	//声明日志对象 logback
	private final static Logger logger = LoggerFactory.getLogger(DealServiceImpl.class);
	private final static String nameSpace = "com.chnbst.bstyun.mapper.DealMapper";

	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean insertDeal(Deal deal) {
		return DaoHelper.insert(nameSpace, "insertDeal", deal);
	}

	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<Deal> selectDealsByCondition(Map<String, Object> map) {
		return (List<Deal>) DaoHelper.list(nameSpace, "selectDealsByCondition", map);
	}

	@Override
	public Deal selectDealByDealNum(String dealNum) {
		return (Deal) DaoHelper.query(nameSpace, "selectDealByDealNum", dealNum);
	}

	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<DealVo> selectDealList(Map<String, Object> map) {
		return (List<DealVo>) DaoHelper.list(nameSpace, "selectDealList", map);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public int selectDealCountByUserId(Integer userId) {
		return DaoHelper.count(nameSpace, "selectDealCountByUserId", userId);
	}
	

}
